//
//  HWYouxiLiBaoTableViewCell.m
//  HWanGame
//
//  Created by 陈道斌 on 2019/9/9.
//  Copyright © 2019 Chendaobin. All rights reserved.
//

#import "HWYouxiLiBaoTableViewCell.h"
#import "HWlibaobagtankuanView.h"

@interface HWYouxiLiBaoTableViewCell()
@property (weak, nonatomic) IBOutlet UIView *beijingView;
@property (weak, nonatomic) IBOutlet UIButton *lingQuBut;

@property (weak, nonatomic) IBOutlet UILabel *namemingchengLabel;
@property (weak, nonatomic) IBOutlet UILabel *libaoneirongLabel;
@property (weak, nonatomic) IBOutlet UILabel *youxiaqilabel;
@property (weak, nonatomic) IBOutlet UILabel *shengyushulianLabel;


@end


@implementation HWYouxiLiBaoTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    self.beijingView.layer.cornerRadius = 12;
    self.beijingView.layer.masksToBounds = YES;
    self.lingQuBut.layer.cornerRadius = 12;
    self.lingQuBut.layer.masksToBounds = YES;
    
     [self.lingQuBut  addTarget:self action:@selector(lingqutap:) forControlEvents:UIControlEventTouchUpInside];
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}



- (void)setDataDic:(NSDictionary *)dataDic {
    
    _dataDic = dataDic;
    

    self.namemingchengLabel.text = [NSString stringWithFormat:@"%@",dataDic[@"cardname"]];
    
     self.libaoneirongLabel.text = [NSString stringWithFormat:@"礼包内容: %@",dataDic[@"content"]];
    
    self.youxiaqilabel.text = [NSString stringWithFormat:@"有效时间: %@",dataDic[@"end_time"]];
    
    self.shengyushulianLabel.text = [NSString stringWithFormat:@"剩余: %@",dataDic[@"cate"]];
    
    
    
    
    
    
    
}


- (void)lingqutap:(UIButton *)sender {
    
    
    NSLog(@"%@",self.dataDic[@"cardname"]);
    
        NSString *uidStr = [NSString stringWithFormat:@"%@",[HWLocallyStoredData getLoginUserID]];
       
         int r =  [WMUtil getRandomNumber:101 to:998];
         NSString *tStr = [NSString stringWithFormat:@"%ld%d",[WMUtil getTimeSp],r];
         
       
         NSString *singStr = [NSString stringWithFormat:@"%@%@%@",uidStr,tStr,@"fsd213ewdsadqwe2121213edsad"];
         
         NSString *singMD5 = [WMUtil md5HexDigest:singStr];
        NSString *idstr = [NSString stringWithFormat:@"%@",self.dataDic[@"id"]];
    


       //   self.dataMuArr = [[NSMutableArray alloc]init];
         NSDictionary *parametes = @{
                                         
                                            @"ios" : @"1",
                                            @"ct" :  @"app",
                                            @"ac" : @"get_lb",
                                            @"uid" :uidStr,
                                            @"t" : tStr,
                                            @"sign" : singMD5,
                                             @"id"  :idstr
                                            };
            
            [HWWebUtils doGetWithParameters:parametes progress:nil success:^(id response) {
                
                // [SVProgressHUD dismiss];
        
                
                NSString *codeStr =  [NSString stringWithFormat:@"%@",response[@"code"]];
                
                if ([codeStr intValue] == 1) {
                    
            
                    // [MBProgressHUD showError:response[@"message"]];
                    
                    HWlibaobagtankuanView  *biaoqian = [[HWlibaobagtankuanView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kScreenH)];
                    
                    biaoqian.zifuchuanStr  = [NSString stringWithFormat:@"%@",response[@"data"]];
                    
                    [kKeyWindow addSubview:biaoqian];
                    
                    
                    
    
                    
         
                } else {
                    
                    [MBProgressHUD showError:response[@"message"]];
                                    
                    
                }
             
                
                
            } failure:^(NSString *error) {
                
                    [MBProgressHUD showError:@"领取失败"];
                
            }];
       
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
}






@end
